using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using DAL.IRepository;
using Entities;
using DAL;
using System.Linq;

namespace WindowsApp.QLThoiKhoaBieuDN
{
    public partial class frmChonLop : DevComponents.DotNetBar.Office2007Form
    {
        private IGeneralRepository<LopHoc> _repository;
        private bool _selectAll = false;
        public List<string> ds = new List<string>();
        public frmChonLop()
        {
            InitializeComponent();
            dgvDSLop.AutoGenerateColumns = false;
        }

        private void frmChonLop_Load(object sender, EventArgs e)
        {
            _repository = new GeneralRepository<LopHoc>();
            dgvDSLop.DataSource = _repository.GetAll().ToList();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in dgvDSLop.Rows)
            {
                if (row.Cells[0].Value != null && row.Cells[0].Value.Equals(true))
                    ds.Add(row.Cells[1].Value.ToString().ToUpper());
            }
        }

        private void dgvDSLop_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.ColumnIndex == 0 && dgvDSLop.Rows.Count > 0)
            {
                _selectAll = !_selectAll;
                for (int idx = 0; idx < dgvDSLop.Rows.Count; idx++)
                {
                    dgvDSLop.Rows[idx].Selected = _selectAll;
                    dgvDSLop.Rows[idx].Cells[0].Value = _selectAll;
                }
            }
        }
    }
}